#include <string.h>

#define MAX_SIZE 1024
typedef int Datatype;

struct Stack
{
    Datatype data[MAX_SIZE];
    int top;
};

typedef struct Stack Stack;

void InitStack(Stack *S)
{
    S->top = 0;
    memset(S->data, 0, sizeof(S->data));
}

int EmptyStack(Stack *S)
{
    return S->top == 0;
}

int FullStack(Stack *S)
{
    return S->top == MAX_SIZE - 1;
}

void PushStack(Stack *S, Datatype data)
{
    if ( FullStack(S) )
    {
        return;
    }

    S->data[S->top++] = data;
}

int PopStack(Stack *S)
{
    if ( EmptyStack(S) )
    {
        return (-1);
    }
    
    return S->data[--S->top];
}